#!/usr/bin/env python3

# pass是空语句，为了保持程序结构的完整性

n = 100
counter = 1
sum = 0;

while counter <= n:
    sum = sum + counter
    counter += 1;
print("1 到 %d 之和为：%d"%(n,sum))

print('--------------------------------------------------------------------------')

count = 0
while count < 5:
   print(count, " 小于 5")  # ，可以在前面也可以在后面
   count = count + 1
#    if count > 3:
#        print('test break')
#        break               # continue用于结束此次循环，开始下一次
else:
   print (count, " 大于或等于 5")   # else 只执行一次

print('--------------------------------------------------------------------------')

sites = ["baidu", "ali", "google", "end"]

for site in sites:
    if site == "end":
        print("find end in sites")
        # break #无此句则会最终到大else
    else:
        print("content:", site)
else:  # 循环遍历结束时到达这里
    print("循环结束!")

print("anyway finished!")
print('--------------------------------------------------------------------------')

for i in range(5):  # 生成数列 0~ 5-1
    print("range(5):", i)

for i in range(5, 9):  # 生成数列5~ 9-1
    print("range(5:9):", i)

for i in range(0,10,3): # 生成数列0~10-1 步长3
    print("range(0,10,3):", i)

a = ['Google', 'Baidu', 'Runoob', 'Taobao', 'QQ'] # 列表
for i in range(len(a)): # len为真实长度 从1开始 5个
    print("range(len()):",i,a[i])

list_test = list(range(5)) # 右值为类型和对应的运算符
for i in list_test:
    print("list(range(5)):",list_test[i])